<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>商家列表</title>
	<meta name="decorator" content="default"/>
	<%@include file="/WEB-INF/views/include/treetable.jsp" %>
	
	<style type="text/css">  
		.loading{  
		    width:160px;  
		    height:56px;  
		    position: absolute;  
		    top:50%;  
		    left:50%;  
		    line-height:56px;  
		    color:#fff;  
		    padding-left:60px;  
		    font-size:15px;  
		    background: #000 url(${ctxStatic}/images/loader.gif) no-repeat 10px 50%;  
		    opacity: 0.7;  
		    z-index:9999;  
		    -moz-border-radius:20px;  
		    -webkit-border-radius:20px;  
		    border-radius:20px;  
		    filter:progid:DXImageTransform.Microsoft.Alpha(opacity=70);  
		}
		
</style>
	<script type="text/javascript">
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
	    	return false;
	    }
		
		function validateOfficeGrade(grade){
			//四级经销商一下不能添加
			if(grade ==5){
				$("#warning").show();
				return false;
			}
	    }
		
	   </script>
</head>
<body>
	 <div id="warning" style="display:none" class="alert alert-warning" aria-hidden="true">
		   <a class="closed close" href="#">×</a>
		   <strong>提示！</strong>当前已是4级经销商，系统暂不支持添加下级经销商!
	</div>

     <div id="loading" class="loading" style="display: none"></div> 
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/sys/office/commonList">商家列表</a></li>
		<c:if test="${isCompPrincipal ==true }">
		   <shiro:hasPermission name="sys:office:edit"><li><a href="${ctx}/sys/office/commonForm">商家添加</a></li></shiro:hasPermission>
		</c:if>
	</ul>
	<form:form id="searchForm" modelAttribute="office" action="${ctx}/sys/office/commonList" method="post"
		class="breadcrumb form-search">
		<div style="margin-top: 8px;">
			<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}" />
		    <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}" />
		    
		    <input name="parentId" type="hidden" value="${parentId}" />
			<label>商家名称：</label>
			<form:input path="name" maxlength="50" type="text"  
				class="input-medium" value="${name }" />
			<label>渠道编码：</label>
			<form:input path="code" maxlength="50" type="text"  
				class="input-medium" value="${code }" />
			&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit"
				value="查询" onclick="return search();" />
		</div>
	</form:form>
	<tags:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
			    <th>商家名称</th>
			    <th>渠道编码</th>
			    <th>经销商级别</th>
			    <th>归属区域</th>
			    <th>通路</th>
			<shiro:hasPermission name="sys:office:edit">
		        <th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="office">
				<tr>
					<td><a  title="点击进入下级机构列表" href="${ctx}/sys/office/commonList?parentId=${office.id}">${office.name}</a></td>
					 <td>${office.code}</td>
					 <td>${dic:getDictLabel(office.grade, 'sys_office_grade', '无')}</td>
					<td>${office.area.name}</td>
				   <td>${office.route.name}</td>
					<shiro:hasPermission name="sys:office:edit"><td>
					
					<c:if test="${ isCompPrincipal ==true}">
					   <a href="${ctx}/sys/office/commonForm?id=${office.id}">修改</a>
					   <a href="${ctx}/sys/office/commonForm?parent.id=${office.id}" onclick="return validateOfficeGrade(${office.grade})">添加下级机构</a> 
					</c:if>
					<a href="${ctx}/sys/office/view?id=${office.id}">查看</a>
					
				</td></shiro:hasPermission>
					
					
				
				</tr>
			</c:forEach>
		
		</tbody>
	</table>
	<div class="pagination">${page}</div> 
	
	<div class="form-actions">
			<input id="btnCancel" class="btn" type="button" value="返 回"
				onclick="history.go(-1);return false;" />
		</div>
</body>
</html>